package top.lyjwn.todo.weinxin.api.url;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.lyjwn.todo.weinxin.param.WXBjnewsParam;

@Component
public class WXBjnewsUrl {


	@Autowired
	private WXBjnewsParam wxBjnewsParam;

	/**
	 * 获取基础access_token接口
	 */
	private String APP_ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{secret}";

	/**
	 * 基础，发送消息接口，客服接口-发消息
	 */
	private String SERVICE_SEND_MESSAGE = "https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=#{ACCESS_TOKEN}";

	/**
	 * 获取用户code接口
	 */
	private String USER_CODE = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{appid}&redirect_uri=#{REDIRECT_URI}&response_type=code"
			+ "&scope=#{SCOPE}&state=#{STATE}#wechat_redirect";

	/**
	 * 用户access_token接口
	 */
	private String USER_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{appid}&secret=#{secret}&code=#{CODE}&grant_type=authorization_code";

	/**
	 * 刷新用户access_token接口
	 */
	private String USER_REFRESH_TOKEN = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=#{appid}&grant_type=refresh_token&refresh_token=#{REFRESH_TOKEN}";

	/**
	 * 拉取用户信息
	 */
	private String PULL_WXUSER_INFO = " https://api.weixin.qq.com/sns/userinfo?access_token=#{ACCESS_TOKEN}&openid=#{OPENID}&lang=#{LANG}";

	public String getAPP_ACCESS_TOKEN() {
		return APP_ACCESS_TOKEN.replace("#{appid}",wxBjnewsParam.getAppid()).replace("#{secret}",wxBjnewsParam.getAppsecret());
	}

	public String getSERVICE_SEND_MESSAGE() {
		return SERVICE_SEND_MESSAGE;
	}

	public String getUSER_CODE() {
		return USER_CODE.replace("#{appid}",wxBjnewsParam.getAppid());
	}

	public String getUSER_ACCESS_TOKEN() {
		return USER_ACCESS_TOKEN.replace("#{appid}",wxBjnewsParam.getAppid()).replace("#{secret}",wxBjnewsParam.getAppsecret());
	}

	public String getUSER_REFRESH_TOKEN() {
		return USER_REFRESH_TOKEN.replace("#{appid}",wxBjnewsParam.getAppid());
	}

	public String getPULL_WXUSER_INFO() {
		return PULL_WXUSER_INFO;
	}
}
